//package com.scs.application.interceptor;
//
//import org.springframework.stereotype.Component;
//import org.springframework.web.filter.OncePerRequestFilter;
//
//import javax.servlet.FilterChain;
//import javax.servlet.ServletException;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//
////防止重复提交
//@Component
//public class OncePerRequestFilterCustom extends OncePerRequestFilter {
//
//    @Override
//    protected void doFilterInternal(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, FilterChain filterChain) throws ServletException, IOException {
//        // 检查请求是否重复
//        if (isRepeatSubmit(httpServletRequest)) {
//            // 如果重复，返回错误信息
//            httpServletResponse.setContentType("application/json");
//            httpServletResponse.setCharacterEncoding("UTF-8");
//            httpServletResponse.getWriter().write("{\"error\":\"重复提交\"}");
//            httpServletResponse.getWriter().flush();
//            httpServletResponse.getWriter().close();
//            return;
//        }
//        filterChain.doFilter(httpServletRequest, httpServletResponse);
//    }
//
//    private boolean isRepeatSubmit(HttpServletRequest request) {
//        // 获取请求中的token
//        String token = request.getHeader("Authorization");
//        // 检查token是否有效
//        if (token == null || token.isEmpty()) {
//            return true;
//        }
//        // 检查token是否重复
//        // 这里需要实现具体的token检查逻辑，例如检查redis中的token是否与请求中的token相同
//        return false;
//    }
//}
